<?php
  include 'database.php';

  //
  $postsql='select count(*) as total from posts';
  $res=mysql_query($postsql);
  $postrow=mysql_fetch_assoc($res);
  //统计文章草稿
  $draftedsql="select count(*) as total from posts where status='drafted'";
  $res=mysql_query($draftedsql);
  $draftedrow=mysql_fetch_assoc($res);
  //统计分类
  $catsql='select count(*) as total from categories';
  $res=mysql_query($catsql);
  $catrow=mysql_fetch_assoc($res);
  //统计评论
  $comsql='select count(*) as total from comments';
  $res=mysql_query($comsql);
  $comrow=mysql_fetch_assoc($res);
  //带审核
  $heldsql='select count(*) as total from comments where status="held"';
   $res=mysql_query($heldsql);
  $heldrow=mysql_fetch_assoc($res);
  ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>阿里百秀登录管理</title>
  <link rel="stylesheet" href="../assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="../assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="../assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="../assets/css/admin.css">
  <script src="../assets/vendors/nprogress/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    <nav class="navbar">
      <button class="btn btn-default navbar-btn fa fa-bars"></button>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="profile.php"><i class="fa fa-user"></i>个人中心</a></li>
        <li><a href="header.php"><i class="fa fa-sign-out"></i>退出</a></li>
      </ul>
    </nav>
    <div class="container-fluid">
      <div class="jumbotron text-center">
        <h1>One Belt, One Road</h1>
        <p>Thoughts, stories and ideas.</p>
        <p><a class="btn btn-primary btn-lg" href="post-add.php" role="button">写文章</a></p>
      </div>
      <div class="row">
        <div class="col-md-4">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">站点内容统计：</h3>
            </div>
            <ul class="list-group">
                <li class="list-group-item"><strong><?php echo $postrow['total']; ?></strong>篇文章（<strong><?php echo $draftedrow['total']; ?></strong>篇草稿）</li>
                <li class="list-group-item"><strong><?php echo $catrow['total']; ?></strong>个分类</li>
                <li class="list-group-item"><strong><?php echo $comrow['total']; ?></strong>条评论（<strong><?php echo $heldrow['total']; ?></strong>条待审核）</li>
            </ul>
          </div>
        </div>
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
      </div>
    </div>
  </div>

<?php include 'aside.php';?>
  <script src="../assets/vendors/jquery/jquery.js"></script>
  <script src="../assets/vendors/bootstrap/js/bootstrap.js"></script>
  <script>NProgress.done()</script>
</body>
</html>
